package platform.xtfw.client;

import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.EventLoop;
import platform.common.CommonInfo;

import java.util.concurrent.TimeUnit;

public class MyChannelFutureListener implements ChannelFutureListener {

    @Override
    public void operationComplete(ChannelFuture channelFuture) throws Exception {
        if(channelFuture.isSuccess()){
            System.out.println("客户端启动");
            return;
        }
        final EventLoop loop = channelFuture.channel().eventLoop();
        loop.schedule(new Runnable() {
            @Override
            public void run() {
                try{
                    new NettyClient().connect(CommonInfo.url,CommonInfo.port);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        },1L, TimeUnit.SECONDS);
    }
}
